const _ = require('underscore');
const uuidV1 = require('uuid/v1');

module.exports = {
    strIsNull(str) {
      return _.isNull(str) || _.isEmpty(str);
    },
    UUID(){
        return uuidV1().replace(new RegExp("-","gm"),'');
    },
    parseMsg(action, payload = {}, metadata = {}) {
      const meta = Object.assign({}, {
        timestamp: Date.now(),
      }, metadata);
  
      return {
        meta,
        data: {
          action,
          payload,
        },
      };
    },
    getTotalPages(records){
      if(records <= 0){
          return 0;
      }
      let totalPages = 0;
      totalPages =Math.floor(records / 10);
      totalPages = records % 10 === 0 ? totalPages:totalPages+1;
      return totalPages;
    }
  };